package com.company.singleton.fork;

public class LazyMan {
    private LazyMan(){
        System.out.println(Thread.currentThread().getName()+",OK");
    }
    private volatile static LazyMan lazyMan;
    public static LazyMan getInstance(){
        if (lazyMan==null){
            synchronized (LazyMan.class){
                if (lazyMan==null){
                    lazyMan=new LazyMan();
                }
            }
        }
        return lazyMan;
    }

    public static void main(String[] args) {
        for (int i = 0; i < 10; i++) {
            new Thread(()->{
                LazyMan instance = LazyMan.getInstance();
            }).start();
        }
    }
}
